﻿using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.Configuration;

namespace ASPNETVN.PORTAL.Controls
{
    public class Marquee : WebControl, INamingContainer
    {
        protected override void Render(HtmlTextWriter writer)
        {
            // BEGIN: Load marquee
            string marquee = string.Empty;
            PortalDataSet ds = PortalConfiguration.GetPortalDataSet();
            DataRow[] rows = ds.Marquee.Select(string.Format("PortalID = '{0}' AND Status = 1", Global.PortalID));
            foreach (DataRow row in rows)
            {
                marquee = string.Format("<marquee scrolldelay='{0}' scrollamount='{1}'><div style='font-weight: bold; color: {3}'>{2}</div></marquee>", row["ScrollDelay"], row["ScrollAmount"], row["Text"], row["ForeColor"]);
                break;
            }
            writer.WriteLine(marquee);
            //END: Load marquee
            base.Render(writer);
        }
    }
}
